home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / popupre / mdiparen.frm < prev    next >
Text File  |  1995-03-03  |  6KB  |  174 lines

  1. VERSION 2.00
  2. Begin MDIForm frmMDIParent 
  3.    Caption         =   "MDI Parent"
  4.    ClientHeight    =   3660
  5.    ClientLeft      =   75
  6.    ClientTop       =   1905
  7.    ClientWidth     =   9405
  8.    Height          =   4065
  9.    Left            =   15
  10.    Top             =   1560
  11.    Width           =   9525
  12.    WindowState     =   2  'Maximized
  13.    Begin PictureBox picToolBar 
  14.       Align           =   1  'Align Top
  15.       BackColor       =   &H00E0E0E0&
  16.       BorderStyle     =   0  'None
  17.       FillColor       =   &H00808080&
  18.       ForeColor       =   &H00808080&
  19.       Height          =   3090
  20.       Left            =   0
  21.       ScaleHeight     =   3090
  22.       ScaleWidth      =   9405
  23.       TabIndex        =   0
  24.       Top             =   0
  25.       Width           =   9405
  26.       Begin Label Label3 
  27.          BackStyle       =   0  'Transparent
  28.          Caption         =   "2.   Close the MDI child window, press the MDI parent image button again and select the popup menu entry 'Show Modal Child Window'. A modal child window similar to the previously opened MDI child window comes up. But if you press its image button which should pop up the same menu as in the MDI child window, no popup menu appears. This happens because of the non-reentrancy of the code of the container window."
  29.          FontBold        =   0   'False
  30.          FontItalic      =   0   'False
  31.          FontName        =   "MS Sans Serif"
  32.          FontSize        =   8.25
  33.          FontStrikethru  =   0   'False
  34.          FontUnderline   =   0   'False
  35.          ForeColor       =   &H00FF0000&
  36.          Height          =   840
  37.          Left            =   585
  38.          TabIndex        =   4
  39.          Top             =   2130
  40.          Width           =   8205
  41.       End
  42.       Begin Label Label2 
  43.          BackStyle       =   0  'Transparent
  44.          Caption         =   "1.   Click on the 'Show MDI Child Window' entry of the popup menu. A MDI child window will open hat also contains an image button with a popup menu. This popup menu is also defined on the hidden container form. If you click on the image button, the popup menu appears. So far, so good."
  45.          FontBold        =   0   'False
  46.          FontItalic      =   0   'False
  47.          FontName        =   "MS Sans Serif"
  48.          FontSize        =   8.25
  49.          FontStrikethru  =   0   'False
  50.          FontUnderline   =   0   'False
  51.          ForeColor       =   &H00FF0000&
  52.          Height          =   675
  53.          Left            =   585
  54.          TabIndex        =   3
  55.          Top             =   1395
  56.          Width           =   8205
  57.       End
  58.       Begin Label Label1 
  59.          BackStyle       =   0  'Transparent
  60.          Caption         =   "The 'MouseDown' event of this image button pops up a menu that is defined on a hidden form (frmMenuContainer)."
  61.          FontBold        =   0   'False
  62.          FontItalic      =   0   'False
  63.          FontName        =   "MS Sans Serif"
  64.          FontSize        =   8.25
  65.          FontStrikethru  =   0   'False
  66.          FontUnderline   =   0   'False
  67.          ForeColor       =   &H00FF0000&
  68.          Height          =   360
  69.          Left            =   585
  70.          TabIndex        =   2
  71.          Top             =   1065
  72.          Width           =   8205
  73.       End
  74.       Begin Label lblMenuClick 
  75.          BackColor       =   &H000000FF&
  76.          ForeColor       =   &H000000FF&
  77.          Height          =   225
  78.          Left            =   8940
  79.          TabIndex        =   1
  80.          Top             =   810
  81.          Visible         =   0   'False
  82.          Width           =   285
  83.       End
  84.       Begin Image imgButtonUp 
  85.          Height          =   330
  86.          Left            =   8895
  87.          Picture         =   MDIPAREN.FRX:0000
  88.          Top             =   45
  89.          Visible         =   0   'False
  90.          Width           =   360
  91.       End
  92.       Begin Image imgButtonDown 
  93.          Height          =   330
  94.          Left            =   8895
  95.          Picture         =   MDIPAREN.FRX:0182
  96.          Top             =   390
  97.          Visible         =   0   'False
  98.          Width           =   360
  99.       End
  100.       Begin Image imgPopUp 
  101.          Height          =   330
  102.          Left            =   4380
  103.          Top             =   135
  104.          Width           =   360
  105.       End
  106.    End
  107. End
  108. Option Explicit
  109.  
  110. Sub HandleMyPopUp (P_nIndex As Integer)
  111. ' This sub handles the clicks on the menu entries of the
  112. ' MDI parent popup menu received by lblMenuClick from frmMenuContainer
  113.  
  114.     Select Case P_nIndex
  115.     Case 0:
  116.         ' Show MDI child window
  117.         frmMDIChild.Show
  118.  
  119.     Case 1:
  120.         ' Show modal child window
  121.         frmModalChild.Show 1
  122.  
  123.     Case 3:
  124.         ' Exit
  125.         End
  126.     
  127.     End Select
  128.  
  129. End Sub
  130.  
  131. Sub imgPopUp_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  132.  
  133.     ' Show 'button down' image
  134.     imgPopUp = imgButtonDown
  135.  
  136.     ' Pop up the MDI parent menu defined in frmMenuContainer
  137.     PopupMenu frmMenuContainer.mnuPopUpMDIParent, 0
  138.  
  139.     ' Show 'button up' image
  140.     imgPopUp = imgButtonUp
  141.  
  142. End Sub
  143.  
  144. Sub lblMenuClick_Change ()
  145. ' The 'Change' event of this label is triggered when a click on
  146. ' a menu entry in frmMenuContainer sets the label caption with the
  147. ' related menu entry index
  148.     
  149.     ' Handle the menu click if an index is available
  150.     If lblMenuClick <> "" Then HandleMyPopUp Val(lblMenuClick)
  151.  
  152.     ' Reset the label for new menu entry clicks
  153.     lblMenuClick = ""
  154.  
  155. End Sub
  156.  
  157. Sub MDIForm_Load ()
  158.     
  159.     ' Startup: Load the hidden menu container form
  160.     Load frmMenuContainer
  161.     
  162.     ' Show 'button up' image initially
  163.     imgPopUp = imgButtonUp
  164.  
  165. End Sub
  166.  
  167. Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  168.  
  169.     ' Ends the app when the system menu is used
  170.     End
  171.  
  172. End Sub
  173.  
  174.